﻿using LY.DataAccess.Repository;
using LY.Entity;
using LY.Entity.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LY.DataAccess.Repositor
{
    public class AccountRepository : BaseRepository
    {
        //根据memberId查询对象
        public U_Account GetAccount(int? id) 
        {
            string sql = @"SELECT [ID]
                          ,[MemberId]
                          ,[AccountName]
                          ,[PayPassword]
                          ,[Status]
                          ,[CreateTime]
                      FROM [U_Account]
                      WHERE MemberId=@MemberId ";
            return base.Get<U_Account>(sql,new {MemberId=id});
        }
        //修改支付密码
        public int UpdatePaypwd(int? id, string password)
        {
            string sql = "update U_Account set PayPassword=@PayPassword where MemberId=@MemberId";
            return base.Excute(sql, new { MemberId = id, PayPassword = password});
        }
       
        //位用户设置支付密码
        public int InserAccount(U_Account account)
        {
            string sql = @"insert into   U_Account(MemberId, AccountName, PayPassword, Status, CreateTime) 
                values(
                @MemberId, 
                @AccountName, 
                @PayPassword, 
                @Status, 
                @CreateTime)
                ";
            return base.Excute(sql, new { MemberId = account.MemberId, AccountName = account.AccountName, PayPassword = account.PayPassword, Status = account.Status, CreateTime = account.CreateTime });
        
        
        }

        
    }
}
